import request from "@/utils/request";
import {
  rootsUrl
} from "../utils";
import {
  getToken
} from "@/utils/auth";

/**
 * 首页轮播图
 */
export const getBanner = () => {
  return request({
    url: `${rootsUrl[0]}/museum/focuspicture/listBanner.shtml`,
    method: "get"
  });
};

/**
 * 获取友情链接
 */
export const getFriendLink = () => {
  return request({
    url: `${rootsUrl[0]}/museum/links/getLinks.shtml`,
    method: "get"
  });
};

// --------------------- 通用列表 -------------------------
// 通用列表页获取列表的接口
export const getList = (navId, pageIndex) => {
  return request({
    url: `${
      rootsUrl[0]
    }/museum/contentManage/getContentListByNavigationId.shtml`,
    method: "get",
    params: {
      navigationId: navId,
      pageIndex,
      pageSize: 10
    }
  });
};

/**
 * 获取中文首页新闻
 */
export const getHomeList = () => {
  return request({
    url: `${
      rootsUrl[0]
    }/museum/contentManage/getContentListByNavigationId.shtml`,
    method: "get",
    params: {
      navigationId: "23,42",
      pageSize: 4
    }
  });
};

export const getEngHomeList = () => {
  return request({
    url: `${
      rootsUrl[0]
    }/museum/contentManage/getContentListByNavigationId.shtml`,
    method: "get",
    params: {
      navigationId: 83,
      pageSize: 4
    }
  });
};

// 特别展览列表页接口
export const getSpecialList = pageIndex => {
  return request({
    url: `${rootsUrl[0]}/museum/spexpo/listSpexpo.shtml`,
    method: "get",
    params: {
      pageIndex
    }
  });
};

// ------------- 典藏  start ----------------
/**
 * 典藏概况类型
 */
export const getCollectionType = () => {
  return request({
    url: `${rootsUrl[0]}/museum/dictionary/listDictionary.shtml`,
    method: "get",
    params: {
      type: 1
    }
  });
};

/**
 * 获取典藏概况列表
 */
export const getCollectionList = (typeId, pageIndex, name) => {
  return request({
    url: `${rootsUrl[0]}/museum/collection/listCollection.shtml`,
    method: "get",
    params: {
      collectionType: 4,
      typeId,
      pageSize: 12,
      name: name || "",
      pageIndex
    }
  });
};

/**
 * 获取精品赏析列表
 */
export const getAppreciateList = () => {
  return request({
    url: `${rootsUrl[0]}/museum/collection/listCollection.shtml`,
    method: "get",
    params: {
      collectionType: 1
    }
  });
};

// ------------------------ 文创 start --------------------------
/**
 * 众筹活动--获取创意征集活动列表
 */
export const getActList = (pageIndex, pageSize) => {
  let token = getToken();
  return request({
    url: `${rootsUrl[3]}/cbculture/act/getActList.shtml`,
    method: "get",
    params: {
      pageIndex,
      pageSize: pageSize || 10,
      token,
      source: "web"
    }
  });
};

/**
 * 文创商品--获取文创商品
 */
export const getProdList = (rtype, pageIndex, title) => {
  console.log(title);
  let token = getToken();
  return request({
    url: `${rootsUrl[3]}/cbculture/prod/getProdList.shtml`,
    method: "post",
    params: {
      pageIndex,
      pageSize: 12,
      token,
      rtype: rtype || "",
      title
    }
  });
};

/**
 * 文创商品--获取文创商品类型列表
 */
export const getProdType = () => {
  return request({
    url: `${rootsUrl[3]}/cbculture/prod/getProdType.shtml`,
    method: "get"
  });
};

//--------------------------- 学习 start -----------------------------
/**
 * 学习--学习指南列表
 */
export const getTutorialList = (pageIndex, pageSize) => {
  let token = getToken();
  return request({
    url: `${rootsUrl[1]}/cbeducate/tutorial/getTutorialList.shtml`,
    method: "get",
    params: {
      token
    }
  });
};

/**
 * 获取证件类型
 */
export const getCardType = () => {
  return request({
    url: `${rootsUrl[0]}/museum/dictionary/listDictionary.shtml`,
    method: "get",
    params: {
      type: 2
    }
  });
};

/**
 * 获取文物征集列表
 */
export const getWenwuCollectionList = () => {
  return request({
    url: `${
      rootsUrl[0]
    }/museum/contentManage/getContentListByNavigationId.shtml?navigationId=30`,
    method: "get"
  });
};

/**
 * 获取文创众筹列表内容
 */
export const getWenChuangZongChouContent = () => {
  return request({
    url: `${
      rootsUrl[0]
    }/museum/contentManage/getContentListByNavigationId.shtml?navigationId=84`,
    method: "get"
  });
};
